#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //创建一个布局管理器
//    QPushButton * p1 = new QPushButton();
//    QPushButton * p2 = new QPushButton();
//    QPushButton * p3 = new QPushButton();

//    QVBoxLayout* layout = new QVBoxLayout(this);
//    layout->addWidget(p1);
//    layout->addWidget(p2);
//    layout->addWidget(p3);

//    this->setLayout(layout);
    QHBoxLayout *hlayout = new QHBoxLayout();
    this->setLayout(hlayout);
    QPushButton * p1 = new QPushButton("按钮1");
    QPushButton * p2 = new QPushButton("按钮2");
    hlayout->addWidget(p1);
    hlayout->addWidget(p2);

    QVBoxLayout * vlayout = new QVBoxLayout();
    QPushButton * p3 = new QPushButton("按钮3");
    QPushButton * p4 = new QPushButton("按钮4");
    vlayout->addWidget(p3);
    vlayout->addWidget(p4);

    hlayout->addLayout(vlayout);


}

Widget::~Widget()
{
    delete ui;
}

